package logic

import (
	"autotestservice/testservices/internal/data"
	"context"
	"gitee.com/jmdvirus/jkgo/jk/jklog"

	"autotestservice/testservices/internal/svc"
	"autotestservice/testservices/internal/types"

	"github.com/tal-tech/go-zero/core/logx"
)

type AutotestserviceGetAllLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewAutotestserviceGetAllLogic(ctx context.Context, svcCtx *svc.ServiceContext) AutotestserviceGetAllLogic {
	return AutotestserviceGetAllLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *AutotestserviceGetAllLogic) AutotestserviceGetAll() (*types.TestItemListResponse, error) {
	jklog.L().Infoln("get all items")
	res := types.TestItemListResponse{
		Code:    0,
		Message: "success",
	}
	data, err := data.AutoTestTestItemGet("")
	if err != nil {
		res.Code = 10
		res.Message = "get fail"
	}
	res.TestIList = *data

	return &res, nil
}
